import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { SceneManager } from './SceneManager';
import { ItemTypeEnum, ItemStatusEnum, SceneEnum } from '../Enum';
import DataManger from '../RunTime/DataManager';
const { ccclass, property } = _decorator;

@ccclass('H4SceneManager')
export class H4SceneManager extends SceneManager {
    @property(Prefab)
    mailPF: Prefab = null

    @property(Node)
    mailPlaceHolder: Node = null

    type: SceneEnum = SceneEnum.H4
    

    rendor() {
        super.rendor()
        this.items.destroyAllChildren()
        const mail = DataManger.Instance.items.find(i => i.type === ItemTypeEnum.Mail)
        if (mail && mail.status === ItemStatusEnum.Scene) {
            const mailnode = instantiate(this.mailPF)
            this.items.addChild(mailnode)
            mailnode.setPosition(this.mailPlaceHolder.position)
        }

    }
}
